
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[BookmarkGroupSelectByTemplateId] @WordTemplateId INT
AS 
    BEGIN
        SELECT  BookmarkGroup.Id ,
                BookmarkGroup.Name ,
                BookmarkGroup.Description ,
                BookmarkGroup.DateCreated ,
                BookmarkGroup.Deleted
        FROM    WordTemplate
                LEFT JOIN WordBookmark ON ( WordTemplate.Id = WordBookmark.WordTemplateId )
                LEFT JOIN BookmarkGroup ON ( WordBookmark.BookmarkGroupId = BookmarkGroup.Id )
        WHERE   WordTemplate.Id = @WordTemplateId
                AND BookmarkGroup.Name IS NOT NULL
        GROUP BY BookmarkGroup.Id ,
                BookmarkGroup.Name ,
                BookmarkGroup.Description ,
                BookmarkGroup.DateCreated ,
                BookmarkGroup.Deleted
    END
GO
